<template>
  <div class="user-column">
    <el-row type="flex" justify="space-between" align="middle" class="survey-hedaer">
      <div class="title">用户看板</div>
      <el-link v-if="linkUrl != ''" :underline="false" type="primary" @click="$router.push({ path: linkUrl })">查看详情</el-link>
      <card-header v-else title="" @change="changeOrderTime" />
    </el-row>

    <el-row :gutter="70" class="user-column-all">
      <el-col :span="12">
        <div class="user-column-title">全部用户</div>
        <el-row type="flex">
          <div class="item">
            <div class="title">累计用户</div>
            <div class="num"><count-roll :number="response.register_count_total" /></div>
            <!-- <el-row type="flex">
              <div class="ratio">日环比：+23%</div>
              <div class="ratio">日环比：+23%</div>
            </el-row> -->
          </div>
          <div class="item">
            <div class="title">新增用户</div>
            <div class="num"><count-roll :number="response.register_count_today" /></div>
            <!-- <el-row type="flex">
              <div class="ratio">日环比：+23%</div>
              <div class="ratio">日环比：+23%</div>
            </el-row> -->
          </div>
          <div class="item">
            <div class="title">活跃用户</div>
            <div class="num"><count-roll :number="response.login_count_late_week" /></div>
            <!-- <el-row type="flex">
              <div class="ratio">日环比：+23%</div>
              <div class="ratio">日环比：+23%</div>
            </el-row> -->
          </div>
        </el-row>
      </el-col>
      <el-col :span="12">
        <div class="user-column-title">付费用户</div>
        <el-row type="flex">
          <div class="item">
            <div class="title">累计用户</div>
            <div class="num"><count-roll :number="response.payment_user_count_total" /></div>
            <!-- <el-row type="flex">
              <div class="ratio">日环比：+23%</div>
              <div class="ratio">日环比：+23%</div>
            </el-row> -->
          </div>
          <div class="item">
            <div class="title">新增用户</div>
            <div class="num"><count-roll :number="response.payment_user_count_today" /></div>
            <!-- <el-row type="flex">
              <div class="ratio">日环比：+23%</div>
              <div class="ratio">日环比：+23%</div>
            </el-row> -->
          </div>
          <div class="item">
            <div class="title">活跃用户</div>
            <div class="num"><count-roll :number="response.payment_user_count_lateweek" /></div>
            <!-- <el-row type="flex">
              <div class="ratio">日环比：+23%</div>
              <div class="ratio">日环比：+23%</div>
            </el-row> -->
          </div>
        </el-row>
      </el-col>
    </el-row>

    <div class="user-column-structure">
      <div class="user-column-title">用户结构</div>
      <el-row :gutter="70">
        <el-col :span="12">
          <div class="structure-scale">
            <div class="structure-title">付费新老用户占比</div>
            <el-row :gutter="79">
              <el-col :span="12"><student-payment-price :rows="response.student_payment_price" /></el-col>
              <el-col :span="12"><student-payment-user :rows="response.student_payment_user" /></el-col>
            </el-row>
          </div>
        </el-col>
        <el-col :span="12">
          <div class="structure-vip">
            <div class="structure-title">会员</div>
            <el-row :gutter="35">
              <el-col :span="12">
                <div class="item">
                  <div class="title">新增会员人数</div>
                  <div class="num"><count-roll :number="response.vip_today" /></div>
                  <!-- <el-row type="flex">
                    <div class="ratio">日环比：+23%</div>
                    <div class="ratio">日环比：+23%</div>
                  </el-row> -->
                </div>
              </el-col>
              <el-col :span="12">
                <div class="item">
                  <div class="title">累计会员人数</div>
                  <div class="num"><count-roll :number="response.vip_total" /></div>
                  <!-- <el-row type="flex">
                    <div class="ratio">日环比：+23%</div>
                    <div class="ratio">日环比：+23%</div>
                  </el-row> -->
                </div>
              </el-col>
            </el-row>
          </div>
        </el-col>
      </el-row>
    </div>

    <!-- <div class="user-column-repeat">
      <div class="user-column-title">复购率</div>
      <el-row :gutter="70">
        <el-col :span="12">
          <el-row :gutter="70">
            <el-col :span="12">
              <div class="item">
                <div class="title">本周</div>
                <div class="num">230</div>
                <el-row type="flex">
                  <div class="ratio">日环比：+23%</div>
                  <div class="ratio">日环比：+23%</div>
                </el-row>
              </div>
            </el-col>
            <el-col :span="12">
              <div class="item">
                <div class="title">本月</div>
                <div class="num">230</div>
                <el-row type="flex">
                  <div class="ratio">日环比：+23%</div>
                  <div class="ratio">日环比：+23%</div>
                </el-row>
              </div>
            </el-col>
          </el-row>
        </el-col>
      </el-row>
    </div> -->
  </div>
</template>

<script>
import CardHeader from '@/pages/vcharts/card/card_header.vue';
import CountRoll from '@/pages/data/components/count_roll';
import StudentPaymentPrice from './components/student_payment_price.vue';
import StudentPaymentUser from './components/student_payment_user.vue';
export default {
  components: {
    CardHeader,
    CountRoll,
    StudentPaymentPrice,
    StudentPaymentUser
  },
  props: {
    // 指定跳转链接,右侧为查看详情按钮,否则为时间选择
    // 暂未时间按时间选择展示数据
    linkUrl: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      time: 'today',
      loading: true,
      response: {}
    };
  },
  created() {
    this.$http.get(
      '/admin/data/survey/today/user',
      {},
      response => {
        this.response = response.data;
        this.loading = false;
      },
      errror => {
        this.loading = false;
      },
      false
    );
  },
  methods: {
    changeOrderTime: function(time) {
      this.time = time;
    }
  }
};
</script>

<style scoped lang="scss">
.user-column {
  background-color: #fff;
  padding: 10px 20px 25px;
  .user-column-title {
    width: 423px;
    height: 30px;
    color: #303133;
    font-size: 14px;
    line-height: 30px;
    padding: 0 10px;
    margin-bottom: 24px;
    background: linear-gradient(90deg, rgba(244, 249, 255, 1) 0%, rgba(255, 255, 255, 1) 100%);
  }
  .user-column-all {
    .item {
      width: 33.33333%;
      padding: 16px 15px;
      border: 1px solid #dcdfe6;
      & + .item {
        border-left: none;
      }
      .title {
        color: #606266;
        font-size: 14px;
        margin-bottom: 12px;
      }
      .num {
        color: #303133;
        font-size: 22px;
        font-weight: bold;
        margin-bottom: 14px;
      }
      .ratio {
        width: 50%;
        color: #303133;
        font-size: 12px;
      }
    }
  }
  .user-column-structure {
    margin-top: 50px;
    .structure-title {
      color: #303133;
      font-size: 14px;
      margin-bottom: 20px;
    }
    .structure-scale {
      .text {
        margin-top: 20px;
        color: #606266;
        font-size: 14px;
      }
      .tag {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        margin-right: 8px;
        &.red {
          background-color: #ff9595;
        }
        &.blue {
          background-color: #7bb4ff;
        }
      }
    }
    .structure-vip {
      .item {
        padding: 17px 33px;
        border: 1px solid #dcdfe6;
        border-radius: 4px;
        .title {
          color: #606266;
          font-size: 14px;
          margin-bottom: 14px;
        }
        .num {
          color: #303133;
          font-size: 22px;
          font-weight: bold;
          margin-bottom: 16px;
        }
        .ratio {
          width: 50%;
          color: #303133;
          font-size: 12px;
        }
      }
    }
  }
  .user-column-repeat {
    margin-top: 50px;
    .item {
      padding: 30px 38px;
      border: 1px solid #dcdfe6;
      border-radius: 4px;
      .title {
        color: #606266;
        font-size: 13px;
        margin-bottom: 10px;
      }
      .num {
        color: #303133;
        font-size: 26px;
        font-weight: bold;
        margin-bottom: 12px;
      }
      .ratio {
        width: 50%;
        color: #606266;
        font-size: 13px;
      }
    }
  }
}
</style>
